
using System;
using System.Collections;
using System.Web.UI.WebControls;

using Awaken.Framework;
using Nullables;

namespace Northwind.Domain.Entities
{
    public partial class Order : IEntity
    {
        protected static OrderBroker broker;
        public static OrderBroker Broker
        {
            get
            {
                if (broker == null)
                {
                    broker = new OrderBroker();
                }
                return broker;
            }
        }

        #region IEntity Members

        public string EntityID
        {
            get { return string.Empty; }
        }
        
        public string EntityName
        {
            get { return string.Empty; }
        }

        public void Save()
        {
            Broker.Save(this);
        }
        
        public void Delete()
        {
            Broker.Delete(this);
        }
        
        #endregion
    
        #region Constructor
        
        public Order()
        {
            // Default, no arg constructor.
        }
        
        #endregion
            
        #region Public Properties / Protected Fields
                        
        
        protected System.Int32? _OrderID;
        public System.Int32? OrderID
        {
            get{ return _OrderID; }
            set{ _OrderID=value; }
        }
        
        protected string _CustomerID;
        public string CustomerID
        {
            get{ return _CustomerID; }
            set{ _CustomerID=value; }
        }
        
        protected System.Int32? _EmployeeID;
        public System.Int32? EmployeeID
        {
            get{ return _EmployeeID; }
            set{ _EmployeeID=value; }
        }
        
        protected DateTime? _OrderDate;
        public DateTime? OrderDate
        {
            get{ return _OrderDate; }
            set{ _OrderDate=value; }
        }
        
        protected DateTime? _RequiredDate;
        public DateTime? RequiredDate
        {
            get{ return _RequiredDate; }
            set{ _RequiredDate=value; }
        }
        
        protected DateTime? _ShippedDate;
        public DateTime? ShippedDate
        {
            get{ return _ShippedDate; }
            set{ _ShippedDate=value; }
        }
        
        protected System.Int32? _ShipVia;
        public System.Int32? ShipVia
        {
            get{ return _ShipVia; }
            set{ _ShipVia=value; }
        }
        
        protected decimal? _Freight;
        public decimal? Freight
        {
            get{ return _Freight; }
            set{ _Freight=value; }
        }
        
        protected string _ShipName;
        public string ShipName
        {
            get{ return _ShipName; }
            set{ _ShipName=value; }
        }
        
        protected string _ShipAddress;
        public string ShipAddress
        {
            get{ return _ShipAddress; }
            set{ _ShipAddress=value; }
        }
        
        protected string _ShipCity;
        public string ShipCity
        {
            get{ return _ShipCity; }
            set{ _ShipCity=value; }
        }
        
        protected string _ShipRegion;
        public string ShipRegion
        {
            get{ return _ShipRegion; }
            set{ _ShipRegion=value; }
        }
        
        protected string _ShipPostalCode;
        public string ShipPostalCode
        {
            get{ return _ShipPostalCode; }
            set{ _ShipPostalCode=value; }
        }
        
        protected string _ShipCountry;
        public string ShipCountry
        {
            get{ return _ShipCountry; }
            set{ _ShipCountry=value; }
        }
        
        
        
        
        
        // Many-To-One: Customers.CustomerID
        protected Customer _Customer;
        public Customer Customer
        {
            get{ return _Customer; }
            set{ _Customer=value; }
        }
        
        // Many-To-One: Employees.EmployeeID
        protected Employee _Employee;
        public Employee Employee
        {
            get{ return _Employee; }
            set{ _Employee=value; }
        }
                
        
        
        // Many-To-Many: Order Details
        protected IList _ProductList;
        public IList ProductList
        {
            get{ return _ProductList; }
            set{ _ProductList=value; }
        }
        
        
        #endregion
    }
    
    #region OrderBroker

    public partial class OrderBroker : IBroker
    {
        #region IBroker Members

        public Type EntityType
        {
            get { return typeof(Order); }
        }
        
        public Order GetByID(object id)
        {
            return (Order)Awaken.Framework.Gateway.GetByID(EntityType, id);
        }

        public IList GetAll()
        {
            return Awaken.Framework.Gateway.GetAll(EntityType);
        }

        public void Save(IEntity entity)
        {
            Awaken.Framework.Gateway.Save(entity);
        }
        
        public void Delete(IEntity entity)
        {
            Awaken.Framework.Gateway.Delete(entity);
        }
        
        #endregion
    }
    #endregion
}
